
// #ifndef VUE3
import Vue from 'vue'
import store from './store'
import App from './App'
import http from './common/http.js'
// import VConsole from "vconsole"
// const vConsole = new VConsole()
// Vue.use(vConsole)
import {VueJsonp} from 'vue-jsonp' 
Vue.use(VueJsonp)
Vue.config.productionTip = false
// Vue.config.ignoredElements = ['wx-open-subscribe']
Vue.config.ignoredElements = [...Vue.config.ignoredElements, 'wx-open-subscribe']
const msg = (title, duration=1500, mask=false, icon='none')=>{ 
    //统一提示方便全局修改
    if(Boolean(title) === false){ 
        return; 
    }
    uni.showToast({ 
        title, 
        duration,
        mask,
        icon
    });
}
App.mpType = 'app'
Vue.prototype.$from = function(){
	var from = '';
	// #ifdef H5
		var ua = window.navigator.userAgent.toLowerCase();
		if(ua.match(/MicroMessenger/i) == 'micromessenger' || ua.match(/_SQ_/i) == '_sq_'){
			from = 'weixin'
		}else{
			from = 'h5'
		} 
	// #endif
	// #ifdef APP-PLUS
		from ='app'
	// #endif
	
	return from;
}
Vue.prototype.$image =function(src) {
	return new Promise(function(resolve,reject){
		let _this = this
		let imgSrc = "";
		setTimeout(()=>{
			uni.getImageInfo({
			    src,
			    success:(res)=>{
					console.log(res,'------res')
					let canvasWidth = res.width //图片原始长宽
			        let canvasHeight = res.height
			        let ratio = canvasWidth / canvasHeight;
			        if (canvasWidth > 500) {
			            canvasWidth = 500;
			            canvasHeight = Math.floor(canvasWidth / ratio);
			        }
					console.log(ratio,'------------123')
					let img = new Image()
			        img.src = res.path
			        let canvas = document.createElement('canvas');
			        let ctx = canvas.getContext('2d')
			        canvas.width = canvasWidth
			        canvas.height = canvasHeight
			        ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight)
			        canvas.toBlob(function(fileSrc) {
						imgSrc = window.URL.createObjectURL(fileSrc)
						console.log(imgSrc)
						resolve({data:imgSrc})
			        })
			    }
			})
		},500)
	})
}
Vue.prototype.service = 'https://oto.uxdj.com.cn/';    //图片上传域名  测试
// Vue.prototype.service = 'https://oto.niyuedaojia.cn';    //图片上传域名  正式
Vue.prototype.$http = http
Vue.prototype.$api = {msg};
const app = new Vue({
    ...App,
	store
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif